home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / eText5 / Source / NewXTeXT / XText0.9beta2 / XText.subproj / XText.h < prev    next >
Encoding:
Text File  |  1995-07-28  |  3.4 KB  |  101 lines

  1. #import <appkit/appkit.h>
  2. #import <stdio.h>
  3. #import <bsd/libc.h> // sleep in the match: method
  4.  
  5. #import "XText0.h"
  6. #import "XTAction.h"
  7. #import "ErrorStream.h"
  8.  
  9. #define BOF 255 // begining of file
  10. /*    XText augments XText0 with a bunch of useful methods for emacs-like
  11.     key bindings.
  12.  
  13.     All of the cursor-movement methods take a 'mode' argument, which may
  14.     be
  15.         0        just move the point to new location
  16.         1        delete to new location
  17.         2        cut to new location
  18.         3        extend selection to new location
  19.     
  20.     The methods are
  21.         goto:end:mode:        implements all movement; second argument specifies
  22.                             the other end of the selection when mode != 0
  23.         moveWord:mode:        move n words forward from point (back if n<0)
  24.         moveChar:mode:        move n chars forward from point (back if n<0)
  25.         moveLine:mode:        move n lines down from point (up if n<0)
  26.         lineBegin:            move to beginning of current line
  27.         lineEnd:            move to end of current line
  28.         docBegin:            move to beginning of document
  29.         docEnd:                move to end of document
  30.         collapseSel:        move to beginning of selection (dir<0), end of
  31.                             selection (dir>0), or active end of sel (dir=0)
  32.         transChars            transpose characters around point
  33.         openLine            insert new line after point
  34.         scroll::            scroll window n pages + m lines
  35.         scrollIfRO::        scroll window n pages + m lines if doc is
  36.                             read-only; returns nil if doc is editable
  37.         insertChar:            inserts the character associated with a key event
  38.         insertNextChar        sets nextAction so that the next key event will be
  39.                             interpreted as a character
  40.  
  41.         autoIndent            creates a new line with space and tab indentation
  42.                             equal to the current line        
  43.         match:"LR"            Finds previous correctly nested matched character
  44.                              L and briefly displays it; then prints R.  
  45.                             Useful for "()" "{}" and "[]".   
  46.     
  47.  
  48.  
  49.     When there is a non-empty selection, we keep track of which end is active
  50.     (further movement commands will be relative to that end).  When we move
  51.     up or down lines, we keep track of which column we started in and try to
  52.     stick to it.  XText's instance variables are used to implement this
  53.     behavior:
  54.         posHint        the cp of the point; if this doesn't correspond to either
  55.                     end of the selection, we put the point after the selection
  56.         xHint        the column we're trying to keep the point in during
  57.                     vertical movement
  58.         xHintPos    xHint is only valid if this is the cp of the point
  59.     ("cp" == character position)
  60.  
  61.     This file also includes initbase_emacs, called by XTDispatchAction's
  62.     initBase:estream: method when base == "emacs" to set up the default
  63.     key bindings.
  64. */
  65.  
  66. @interface XText:XText0
  67. {
  68.     int posHint;
  69.     int xHint;        // note that this is in characters, not pixels
  70.     int xHintPos;
  71. }
  72. - goto:(int)pos end:(int)end mode:(int)mode;
  73. - moveWord:(int)cnt mode:(int)mode;
  74. - moveChar:(int)cnt mode:(int)mode;
  75. - moveLine:(int)cnt mode:(int)mode;
  76. - lineBegin:(int)mode;
  77. - lineEnd:(int)mode;
  78. - docBegin:(int)mode;
  79. - docEnd:(int)mode;
  80. - collapseSel:(int)dir;
  81. - transChars;
  82. - openLine;
  83. - autoIndent;
  84. - scroll:(int)pages :(int)lines;
  85. - scrollIfRO:(int)pages :(int)lines;
  86. - insertChar:(NXEvent *)event;
  87. - insertNextChar;
  88. // new to XText version 1.0 methods
  89. - autoIndent;
  90. - match:(unsigned char *)LR;
  91. // useful methods to display character codes
  92. - insertKeyCombination:(NXEvent *)event;
  93. - insertKeyCombOfNextKey;
  94. @end
  95.  
  96.  
  97. @interface XText(private)
  98. /* Eliminates the use of ClipView's private _scrollTo: method
  99.  * in XText 0.8 */ 
  100. - scrollTo:(const NXPoint *)newOrigin;
  101. @end